<?php

namespace app\mini\controller\v1\shop;

use app\common\library\exception\ApiException;
use app\common\library\MemberVo;
use app\common\logic\OrderLogic;
use app\mini\controller\Common;
use think\Request;
use think\response\Json;

class Order extends Common
{
    public $OrderLogic;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->OrderLogic = new OrderLogic();
    }

    /**
     * 订单列表
     * @return Json
     */
    public function index(): Json
    {
        $res = $this->exception(function () {
            $params = request()->param();
            $params['shop_id'] = MemberVo::instance()->getShopId();
            return $this->OrderLogic->index($params);
        });
        return $this->response($res);
    }

    /**
     * 订单详情
     * @return Json
     */
    public function detail(): Json
    {
        $res = $this->exception(function () {
            return $this->OrderLogic->detail(request()->param());
        });
        return $this->response($res);
    }

    /**
     * 订单状态数量
     * @return Json
     */
    public function orderStatusNum(): Json
    {
        $res = $this->exception(function () {
            return $this->OrderLogic->orderNum();
        });
        return $this->response($res);
    }

    /**
     * 核销订单
     * @return Json
     */
    public function useOrder(): Json
    {
        $res = $this->transException(function () {
            return $this->OrderLogic->useOrder(request()->param());
        });
        return $this->response($res);
    }
}